/**
 * Description:
 * Class Name:ListIteratorTest
 * Date:2022/3/5 15:13
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第8章_Java集合._8_4_List集合._8_4_1_改进的List接口和ListIterator接口;

import java.util.ArrayList;

public class ListIteratorTest {
    public static void main(String[] args) {
        String[] books = {"疯狂Java讲义", "疯狂IOS讲义", "轻量级Java EE 企业应用实战"};
        var bookList = new ArrayList();
        for (int i = 0; i < books.length; i++) {
            bookList.add(books[i]);
        }
        var lit = bookList.listIterator();
        // 从前向后遍历
        while (lit.hasNext()){
            System.out.println(lit.next());
            lit.add("------分隔符------");
        }
        System.out.println("===========下面开始反向迭代===========");
        // 从后向前遍历
        while (lit.hasPrevious()){
            System.out.println(lit.previous());
        }
    }
}
//疯狂Java讲义
//疯狂IOS讲义
//轻量级Java EE 企业应用实战
//===========下面开始反向迭代===========
//------分隔符------
//轻量级Java EE 企业应用实战
//------分隔符------
//疯狂IOS讲义
//------分隔符------
//疯狂Java讲义